//
//  DKRegisterVoiceView.m
//  DanKU
//
//  Created by 吴斌 on 2023/9/19.
//

#import "DKRegisterVoiceView.h"

@implementation DKRegisterVoiceView
-(instancetype)init{
    if(self == [super init]){
        self.backgroundColor = UIColor.clearColor;
        [self dk_addSubView];
    }
    return self;
}
- (void)dk_addSubView{
    UILabel *dk_RegisterVoiceLab = [[UILabel alloc] init];
    dk_RegisterVoiceLab.textColor = DK_Hex(@"#333333");
    dk_RegisterVoiceLab.font = DK_FONT_Regular(12);
    dk_RegisterVoiceLab.text = @"You can also try voice verification code >";
    [self addSubview:dk_RegisterVoiceLab];
    [dk_RegisterVoiceLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(-DK_IsWidthScale(0)));
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.bottom.equalTo(@(-DK_IsWidthScale(0)));
    }];
    UIImageView* dk_RegisterVoiceImgView = [[UIImageView alloc] init];
    dk_RegisterVoiceImgView.userInteractionEnabled = YES;
    dk_RegisterVoiceImgView.image = DK_GetImage(@"dk_registerVoice");
    dk_RegisterVoiceImgView.contentMode = UIViewContentModeScaleToFill;
    [self addSubview:dk_RegisterVoiceImgView];
    [dk_RegisterVoiceImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(dk_RegisterVoiceLab.mas_left).offset(-DK_IsWidthScale(10));
        make.centerY.equalTo(dk_RegisterVoiceLab);
        make.height.equalTo(@(DK_IsWidthScale(17)));
        make.width.equalTo(@(DK_IsWidthScale(12)));
    }];
    
    UIButton * dk_RegisterVoiceBtn = [[UIButton alloc] init];
    [dk_RegisterVoiceBtn addTarget:self action:@selector(goRegisterVoice) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:dk_RegisterVoiceBtn];
    [dk_RegisterVoiceBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(dk_RegisterVoiceImgView);
        make.right.equalTo(dk_RegisterVoiceLab);
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.bottom.equalTo(@(-DK_IsWidthScale(0)));
    }];
}
- (void)goRegisterVoice{
    if(self.goRegisterVoiceBlock){
        self.goRegisterVoiceBlock();
    }
}
@end
